﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tesla.Service.WcfServiceCommon;
using Tesla.Business.BusinessLogic;
using Tesla.Service.DataContracts;
using Tesla.Util.Utilities;
using System.ServiceModel;
using System.Data.SqlClient;
using Tesla.Service.ServiceContracts;
using Tesla.Business.BusinessLogic.Implementations;
using Tesla.Business.BusinessLogic.Interfaces;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling;
using Microsoft.Practices.EnterpriseLibrary.Logging;

namespace Tesla.Service.ServiceImplementations
{
    public class SvcUserLogin : ISvcUserLogin
    {
        public void ValidateUser(string userName, string password, ref bool? userExists)
        {
            try
            {
                using (ContextBL cBL = new ContextBL())
                {
                    IUserLoginBL iblUserLogin = cBL.CreateSpecializedBL(EntityMapper.USERLOGINBL) as IUserLoginBL;
                    iblUserLogin.ValidateUser(userName, password, ref userExists);
                }
            }
            catch (Exception ex)
            {
                bool rethrow = ExceptionPolicy.HandleException(ex, "GADN Custom Exception Policy");
                if (rethrow)
                    throw;
            }
        }
    }
}

